<?php
header('Content-type:text/html;charset=utf8');
/**
 * 是否可用切换类
 * xysc users Version1.0
 * ==================================
 * Copy 2016-2017
 * Web:www.xjh7.com
 * ==================================
 * Author:xjh
 * Date:2016-4-1
*/

class active {
	/**
	 * 
	 * @param int $id 操作的id
	 * @param int $active_id 是与否的标志
	 * @param string $tableName 操作的表名
	 * @param string $fieldId 操作的字段(一般是ID)
	 * @return true or false 成功返回1，失败返回0
	 */
	public function setActive($id,$active_id,$tableName,$fieldId){
		$cmodel = new CCCModel();
		if($active_id == 1){
			$_sql = "UPDATE {{".$tableName."}} set active=0  WHERE $fieldId = ".$id;
			$row = $cmodel->upd($_sql);
		}else{
			$_sql = "UPDATE {{".$tableName."}} set active=1  WHERE $fieldId = ".$id;
			$row = $cmodel->upd($_sql);
		}
		return $row;
	}
}

?>